<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1,minimum-scale=1,user-scalable=no">		<meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <link rel="stylesheet" type="text/css" href="/public/static/wx/css/base.css" />
    <link rel="stylesheet" type="text/css" href="/public/static/wx/font/font-awesome-4.7.0/css/font-awesome.css" />
    <link rel="stylesheet" type="text/css" href="/public/static/wx/plug-in/layui/css/layui.css" />
    <link rel="stylesheet" type="text/css" href="/public/static/wx/css/choose-engineer.css" />
    <script src="/public/static/wx/js/flex.js" type="text/javascript" charset="utf-8"></script>

    <title>可选工程师</title>
    <style>
        .active span{
            background-size: 22px !important;
            background-position: -1px -3px !important;
        }

        .head{
            background-size: 36px !important;
            background-position: 6px 10px !important;
        }
    </style>
</head>
<body>
<div class="index">
    <!--<div class="title">可选工程师</div>-->
    <div class="engineer-list" id="dataList">
        <!--<div class="engineer clearfix">
            <div class="head"></div>
            <div class="name">1号工程师</div>
            <span></span>
            <div class="level">中级</div>
        </div>-->
        
    </div>
</div>
<div class="certain" id="btn">确定</div>
<script src="/public/static/wx/js/jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/public/static/wx/plug-in/layui/layui.all.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
    var layer = layui.layer;
    var url = '';

    var did = '{:input("id")}';
    var isa = '{:input("a")}';

    if(isa == 's'){
        url = '{:url("team")}';
    }else{
        url = '{:url("addTeam")}';
    }

    $.post('{:url("query")}',{is_at:0},function (data) {
        if(data.data.length<=0){
            $('#dataList').html('<div style="font-size: 17px;color: #999;"><span>没有空闲的工程师</span><span>你还可以去<a href="{:url("enginAddUI")}" style="color: blue;">添加</a>工程师</span></div>');
        }

        $.each(data.data,function (k,v) {

            var str = '<div class="engineer clearfix" aid="'+v.admin_id+'">\n' +
                '            <div class="head"><img src="" alt=""></div>\n' +
                '            <div class="name" style="font-size: 17px;">'+v.name+'('+v.username+')</div>\n' +
                '            <span></span>\n' +
                '            <div class="level">'+v.title+'</div>\n' +
                '        </div>';

            $('#dataList').append(str);
        });


        $('.engineer').on('click',function(){
            $(this).toggleClass('active');
            $(this).toggleClass('ided');
        });

    });


    $('#btn').click(function () {
        var ids = '';
        $('.ided').each(function (k,v) {
            ids += $(this).attr('aid')+',';
        });


        if(ids.length<=0){
            layer.msg('请选择工程师',{icon:5});
            return;
        }
        var indexl = layer.load(0,{offset:['45%','45%']});
        $.post(url,{dis_id:did,aid:ids},function (res) {
            layer.close(indexl);
            if(res.code == 1){
                layer.msg(res.msg,{icon:6,shade:0.1},function () {
                    location.href = '{:url("teamUI")}?id='+did;
                });
            }else{
                layer.msg(res.msg,{icon:5});
            }
        });

    });


</script>
</body>
</html>
